package com.lt.common;

import com.lt.exception.CustomException;

import java.io.IOException;
import java.io.OutputStream;

public class IoUtils
{
    /**
     * 将byte[]写到流中
     *
     * @param out        输出流
     * @param isCloseOut 写入完毕是否关闭输出流
     * @param content    写入的内容
     * @throws CustomException IO异常
     */
    public static void write(OutputStream out, boolean isCloseOut, byte[] content) throws CustomException
    {
        try
        {
            out.write(content);
        } catch (IOException e)
        {
            throw new CustomException(e);
        } finally
        {
            if (isCloseOut)
            {
                CloseUtils.closeIO(out);
            }
        }
    }
}
